package com.lxx.onlineview.utils;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class ObjectUtil {
    public static Map<String, Object> reflect(Object e) throws Exception {
        Class cls = e.getClass();
        Field[] fields = cls.getDeclaredFields();
        Map<String, Object> result = new HashMap<>();
        for (int i = 0; i < fields.length; i++) {
            Field f = fields[i];
            f.setAccessible(true);
            result.put(f.getName(), f.get(e));
        }
        return result;
    }

}

